package com.ch6.heartbeat;

import com.ch6.Message;
import com.ch6.NettyConstant;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * @author U317076
 *
 */
public class HeartbeatServerHandler extends ChannelInboundHandlerAdapter{

	
	@Override
	public void channelRead(ChannelHandlerContext ctx, Object msg)
			throws Exception {
      
		Message message=(Message)msg;
		if(message==null){
			ctx.pipeline().fireChannelRead(msg);
		}else{
			message.getHeader().setType(NettyConstant.MessageType.HEARTBEAT_RESP.value());
			ctx.pipeline().writeAndFlush(message);
		}
		
	}
	
	
	
}
